<?php

extract(extractPost(), EXTR_PREFIX_ALL, 'u');

if(isset($u_user_id) && isset($u_group_id)){

    $u_id = $u_user_id;

    $result = array();

    $group = R::load('group', $u_group_id );
    $user = R::load('user', $u_id);

    if($group->id == 0)
    {
        jsonErrorDie("Group does not exists. Please use another group id.");
    }
    if($user->id == 0)
    {
        jsonErrorDie("User does not exists. Please use another user id.");
    }

    if(isInBeans($user->id, $group->sharedUserList) && in_array($u_id, json_decode($group->developers)))
    {
        include_once 'deactivateUser.php';
    }
    else if (in_array($u_id, json_decode($group->nonActiveUsers)))
    {
        include_once 'activateUser.php';
    }
    else
    {
        include_once 'addUser.php';
    }

}

jsonErrorDie("Problem occured while inserting deactivated user in database");
